package com.ljt.utils;

import java.io.Serializable;

/**
 * Created by wb-ljt251780 on 2017/7/24.
 */
public class ResponseData implements Serializable{
    private static final long serialVersionUID = -7246026735783651839L;
    private Boolean code;
    private String message;
    private String data;

    public ResponseData() {
    }

    public ResponseData(String message) {
        this.message = message;
    }

    public ResponseData(Boolean code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseData(Boolean code, String message, String data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static ResponseData success(){
        return success("请求成功");
    }
    public static ResponseData success(String message){
        return success(message, null);
    }
    public static ResponseData success(String message,String data){
        return new ResponseData(true,message,data);
    }
    public static ResponseData error(){
        return error("请求出错");
    }
    public static ResponseData error(String message){
       return error(message,null);
    }
    public static ResponseData error(String message,String data){
        return new ResponseData(false,message,data);
    }
    public Boolean getCode() {
        return code;
    }

    public void setCode(Boolean code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ResponseData that = (ResponseData) o;

        if (!code.equals(that.code)) return false;
        if (!data.equals(that.data)) return false;
        if (!message.equals(that.message)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = code.hashCode();
        result = 31 * result + message.hashCode();
        result = 31 * result + data.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "ResponseData{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data='" + data + '\'' +
                '}';
    }
}
